*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Davenport and McDermott 2011 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/mcdermott004.html
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "tess2_068_mcdermott_final_data.dta", clear
set more off

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab PPETHM
tab PPETHM, gen(race)
rename race1 whiteR
rename race2 blackR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

tab XTESS068
tab XTESS068, gen(cond)
rename cond1 whiteCOPblackPROT
rename cond2 blackCOPwhitePROT
rename cond3 whiteCOPwhitePROT
rename cond4 blackCOPblackPROT

gen whitecop = 0
replace whitecop = 1 if whiteCOPblackPROT==1 | whiteCOPwhitePROT==1
gen blackcop = 0
replace blackcop = 1 if blackCOPwhitePROT==1 | blackCOPblackPROT==1
gen whiteprot = 0
replace whiteprot = 1 if blackCOPwhitePROT==1 | whiteCOPwhitePROT==1
gen blackprot = 0
replace blackprot = 1 if whiteCOPblackPROT==1 | blackCOPblackPROT==1

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

tab1 Q1 Q2 Q3 Q4 Q5
recode Q1 Q2 Q3 Q4 Q5 (-1=.)
tab1 Q1 Q2 Q3 Q4 Q5

egen policeFAULT_std = std(Q1)
egen policeNOTproper_std = std(Q3)
sum policeFAULT_std policeNOTproper_std

alpha policeFAULT_std policeNOTproper_std, item
alpha policeFAULT_std policeNOTproper_std, item std min(1) gen(ALPHA)

sum ALPHA if whiteR==1
di r(sd)
gen ov_white_std = ALPHA/r(sd) if whiteR==1

sum ALPHA if blackR==1
di r(sd)
gen ov_black_std = ALPHA/r(sd) if blackR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

// No racial manipulation check

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg ov_white_std whiteCOPblackPROT if (blackCOPwhitePROT==1 | whiteCOPblackPROT==1) & whiteR==1
reg ov_black_std whiteCOPblackPROT if (blackCOPwhitePROT==1 | whiteCOPblackPROT==1) & blackR==1
